const PAGES = 10
Page({

  data: {
		blogList: []
  },

  onLoad(options) {
		this.getMyBlogList()
  },

	getMyBlogList () {
		wx.showLoading({
			title: '加载中...',
		})
		wx.cloud.callFunction({
			name: 'blog',
			data: {
				start: this.data.blogList.length,
				count: PAGES,
				$url: 'getMyBlog'
			}
		}).then(res => {
			const result = res.result
			this.setData({
				blogList: this.data.blogList.concat(res.result)
			})
			wx.hideLoading()
		})
	},
	// 进入详情
	goComment(e) {
		wx.navigateTo({
			url: `../blog-comment/blog-comment?blogId=${e.currentTarget.dataset.blogid}`,
		})
	},
	// 下拉刷新
	onPullDownRefresh() {
		this.setData({
			blogList: []
		})
		this.getMyBlogList()
	},
	// 上了加载
	onReachBottom() {
		this.getMyBlogList()
	},
	// 分享
  onShareAppMessage(e) {
		const result = e.target.dataset.blog
		return {
			title: result.content,
			path: `/pages/blog-comment/blog-comment?blogId=${result._id}`
		}
  }
})